var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

var result = [ ];

var ranNum = 5;

for (var i = 0; i < ranNum; i++) {

var ran = Math.floor(Math.random() * arr.length);

result.push(arr[ran]);

var center = arr[ran];

arr[ran] = arr[arr.length - 1];

arr[arr.length - 1] = center;

arr = arr.slice(0, arr.length - 1);

};